package com.example.gfsquadwebviewproject.net;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.SharedPreferences;

public class AutoStartBroadcastReceiver extends BroadcastReceiver {
	private static final String ACTION = "android.intent.action.BOOT_COMPLETED";
	private SharedPreferences mPreferences = null;

	@Override
	public void onReceive(Context context, Intent intent) {

		mPreferences = context.getSharedPreferences("AutoStart",
				ContextWrapper.MODE_PRIVATE);
		
		if (intent.getAction().equals(ACTION)) {

			if (mPreferences.getBoolean("AddToAuto", false)) {

		        Intent service = new Intent(context,AutoStartService.class);
		        context.startService(service);

				Intent newIntent = context.getPackageManager()
						.getLaunchIntentForPackage("com.example.gfsquadwebviewproject");
				context.startActivity(newIntent);
			}
		}
	}

}
